﻿using BoriPeter.FatSecret.Messages;
using BoriPeter.FatSecret.Converters;
using BoriPeter.FitnessJournal8.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BoriPeter.FitnessJournal8.Interfaces;

namespace BoriPeter.FatSecret
{
    public class FatSecretDailyIntakeDataSource
    {
        public async Task<List<DailyEntry>> GetMonthListAsync(DateTime _dayOfMonth)
        {
            if (FatSecretCommon.AccessToken != null)
            {
                var dailyIntakeGetMonth = new FoodEntriesGetMonth(_dayOfMonth);
                var dailyIntakeList = await dailyIntakeGetMonth.SendAsync();
                return dailyIntakeList.Convert();
            }
            else
                return new List<DailyEntry>();
        }

        public async Task<DailyEntry> GetDailyEntryAsync(DateTime _date, List<Food> _foods)
        {
            if (FatSecretCommon.AccessToken != null)
            {
                var dailyEntryFoods = new FoodEntriesGet(_date);
                var dailyIntakeList = await dailyEntryFoods.SendAsync();
                return dailyIntakeList.Convert(_foods);
            }
            else
                return new DailyEntry() { Date = _date };
        }
    }
}
